﻿using IOP.ISEA;
using IOP.SgrA;
using IOP.SgrA.SilkNet.Vulkan;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace VkSample51
{
    [ModulePriority(ModulePriority.Assets)]
    public class AssetsModule : VulkanModule, IVulkanRenderWapperModule
    {

        public AssetsModule()
        {
        }

        public VulkanRenderWapper RenderWapper { get; set; }

        protected override async Task Load(VulkanGraphicsManager graphicsManager)
        {
            graphicsManager.TryGetRenderGroup("BallGroup", out IRenderGroup group);

            ISEADocument document = new ISEADocument();
            await document.Load(Path.Combine(AppContext.BaseDirectory, "Test51.isea"));
            var renders = await graphicsManager.CreateRenderObjectsFromISEA<RenderObject>(document);
            var archetype = ContextManager.CreateArchetype(new TransformComponent());
            ContextManager.CreateContexts(1, archetype, group, renders[0]);
        }

        protected override Task Unload(VulkanGraphicsManager manager)
        {
            return Task.CompletedTask;
        }
    }
}
